import React, { Component, Fragment } from "react";
import { Text } from "react-native";
import HttpUtil from '../../utils/HttpUtil';
import {View,ActivityIndicator,StyleSheet} from 'react-native'
class SongDetail extends Component {
  constructor(props) {
    super(props);
    this.state = {
      data:{},
      finish: false
    };
  }
  componentDidMount(){
    console.log(this.props.navigation.state.params.id);
    HttpUtil.get(`https://www.mxnzp.com/api/music/song/detail?songId=${this.props.navigation.state.params.id}`).then((res)=>{
      console.log(res);
      this.setState({
        data:res.data,
        finish:true
      })
    })
  }
  render() {
    if (!this.state.finish) {
      return (
        <View style={styles.container}>
          <ActivityIndicator />
        </View>
      );
    }
    return (
      <Fragment>
        <View style={styles.container}>
          <Text>{this.state.data.songName}</Text>
        </View>
      </Fragment>
    );
  }
}
const styles = StyleSheet.create({
  container: {
    backgroundColor: "#eae7ff",
    flex:1,
    justifyContent: 'flex-start'
  }
});
export default SongDetail;
